package com.team.weigou.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.team.weigou.R;
import com.team.weigou.bean.DataEntity;

import java.util.ArrayList;

import de.hdodenhof.circleimageview.CircleImageView;


/**
 * Created by Wangs on 2015/7/6.
 */
public class HotRecommenAdapter extends MyAdapter<DataEntity> {
    private BitmapUtils bitmapUtils;

    public HotRecommenAdapter(Context context, ArrayList<DataEntity> list, BitmapUtils bitmapUtils) {
        super(context, list);
        this.bitmapUtils=bitmapUtils;
    }

    @Override
    public View creatView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_hotrecommen_layout, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.textView.setText(list.get(position).getName());

        Animation animation= AnimationUtils.loadAnimation(context, R.anim.show_grid_item);
        holder.image.startAnimation(animation);
        bitmapUtils.display(holder.image,list.get(position).getImage());
        return convertView;
    }

    public class ViewHolder {
        private CircleImageView image;
        private TextView textView;

        public ViewHolder(View view) {
            image = (CircleImageView) view.findViewById(R.id.hot_recommen_image);
            textView= (TextView) view.findViewById(R.id.hot_recomm_textview);
        }
    }
}
